﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Cloud.Core.Model
{
    /// <summary>
    /// 日志表(SN_Log)
    /// </summary>
    public class Log
    {
        /// <summary>
        /// 主键
        /// </summary>
        public Guid Id { get; set; }
        /// <summary>
        /// 操作人
        /// </summary>
        public string OperateUser { get; set; }
        /// <summary>
        /// 操作时间
        /// </summary>
        public DateTime? OperateTime { get; set; }
        /// <summary>
        /// 日志类型(登录，访问，操作，异常)
        /// </summary>
        public OperateType? LogType { get; set; }
        /// <summary>
        /// 日志内容
        /// </summary>
        public string Content { get; set; }
        /// <summary>
        /// 日志来源
        /// </summary>
        public string Source { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        public string Remark { get; set; }
        /// <summary>
        /// 创建人
        /// </summary>
        public string CreateUserId { get; set; }
        /// <summary>
        /// 修改人
        /// </summary>
        public string ModifyUserId { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreateDate { get; set; }
        /// <summary>
        /// 修改时间
        /// </summary>
        public DateTime? ModifyDate { get; set; }

        /// <summary>
        /// 模块名称
        /// </summary>
        public string ModuleName { get; set; }
        public Log()
        {
            this.Id = Guid.NewGuid();
            this.OperateUser = "";
            this.OperateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.ModifyDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.CreateUserId = "zhengyb";
            this.ModifyUserId = "zhengyb";
        }

        public Log(OperateType operatype, string Content, string remark = "", string Source = "", string createUserid = "zyb", DateTime? createDate = null, string modifyUserid = "", DateTime? modifyDate = null)
        {
            this.Id = Guid.NewGuid();
            this.OperateUser = createUserid;
            this.OperateTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.CreateUserId = createUserid;
            this.CreateDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            this.ModifyUserId = modifyUserid;
            this.ModifyDate = modifyDate;

            this.LogType = operatype;
            this.Content = Content;
            this.Source = Source;
            this.Remark = remark;
        }

        public enum OperateType
        {
            登录 = 0, 访问 = 1, 操作 = 2, 异常 = 3
        }

    }
}
